package com.domain.DO;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.domain.pojo.FlightClassLevel;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 
 * </p>
 *
 * @author 大忽悠
 * @since 2022年11月08日
 */
@Getter
@Setter
@TableName("flight_class")
public class FlightClass implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 班次号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 起飞时间
     */
    private LocalDateTime departureTime;

    /**
     * 起飞机场
     */
    private String departureAirport;

    /**
     * 到达时间
     */
    private LocalDateTime arrivalTime;

    /**
     * 到达机场
     */
    private String arriveAirport;

    /**
     * 商务舱剩余座位
     */
    private Integer richLeftNumber;

    /**
     * 经济舱剩余座位
     */
    private Integer poorLeftNumber;

    /**
     * 商务舱价格
     */
    private Double richPrice;

    /**
     * 经济舱价格
     */
    private Double poorPrice;

    /**
     * 航班号
     */
    private Integer flightId;

    /**
     * 座位信息
     */
    private String seatInfo;

    public FlightClass updateSeatInfo(Integer seatSeq, Integer degree) {
        //1.更新座位map信息
        StringBuilder stringBuilder = new StringBuilder(seatInfo);
        stringBuilder.setCharAt(seatSeq,'1');
        seatInfo=stringBuilder.toString();
        //2.更新剩余座位数量
        FlightClassLevel.decreeNum(degree,this);
        return this;
    }
}
